
cd "C:\Users\neilke\Dropbox\Egypt Event Data\Egypt Mobilization Book\temporal_protest\production\replication\data"

********************************************************************************
* Fig 1.: MB protests Egypt as proportion of activist mobilization 
********************************************************************************

use mbmob_by_month.dta, clear
twoway line pct_mb month, ///
	xlabel(1 "Jan" 6 "Jun" 12 "Dec") ///
	xtitle("") legend(off) ///
	ylabel(0(20)100, nogrid ) ytitle("MB mobilization (% of activist protests)")

********************************************************************************
* Fig 2.: Egypt mass mobilization
********************************************************************************
	
use massmobyegy.dta, clear

twoway bar ppart stdate, xla(18627(7)18992, format("%tdDa") labsize(tiny) labcolor("189 30 36")) ///
xmla(18655 "Friday of Anger" 18662 "Friday of Departure" 18669 "Friday of Departure" 18676 "Friday of Victory" 18683 "Friday of Cleansing" 18690 "Friday of Unity" 18718 "Friday of Saving the Revolution" ///
	18725 "Friday of Cleansing" 18760 "Friday of National Unity" 18774 "Friday of the Second Revolution" 18809 "Friday of Retribution" 18816 "Friday of Determination" ///
	18823 "Friday of the Final Warning" 18830 "Friday of Settlement" 18837 "Friday of Stability" 18879 "Friday of Clearing the Way" 18886 "Friday of No to Sectarianism" ///
	18900 "Friday of Reclaiming the Revolution" 18907 "Friday of Return to the Barracks" 18949 "Friday of One Demand" 18956 "Friday of Last Chance", tlcolor(%20) angle(90) labsize(small) tlength(*10)) xtitle("") 	yline(100000, lcolor("189 30 36")) ysize(4) /// 
ytitle(Protest participation (million), size(small)) lwidth(0) ///
ylabel(0 "0" 500000 "0.5" 1000000 "1" 1500000 "1.5", angle(90) labsize(small) nogrid) ///
plotregion(margin(zero))
	
********************************************************************************
* Fig 3.: Egypt participation by dow and coefplot
********************************************************************************

use egy_prot_expanded.dta, clear

*Friday protest significantly different? Yes - p=.000
oneway ppart dow, tab
pwmean ppart, over(dow) mcompare(tukey) effects

*Non-parametric? Yes - p<.01
kwallis ppart, by(dow)

*Which category dominates? FRIDAY DOMINATES
conovertest ppart, by(dow)

*Evidence for autocorrelation; chi2=34.2; p<.001
tsset date, daily
reg ppart i.dow
estat bgodfrey

*Nbreg with Newey-West SE's
tsset date, daily
glm ppart i.dow, family(nbinom) vce(hac nwest 1)

coefplot, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-4 -2 0 2 4) ///
	ylabel(1 "M" 2 "T" 3 "W" 4 "T" 5 "F" 6 "S", labsize(small))

preserve	
collapse (sum) ppart, by(dow)
twoway bar ppart dow, ///
	tlabel(0 "S" 1 "M" 2 "T" 3 "W" 4 "T" 5 "F" 6 "S") ///
	aspectratio(1) ///
	xtitle("") ///
	ytitle(Protest participation) ylabel(, angle(90) labsize(small)) ///
	ylabel(,nogrid) barw(0.9) 
restore

********************************************************************************
* Fig 4.: Egypt participation by dow and coefplot pre-2011
********************************************************************************

use egy_prot_expandedpr.dta, clear

*Friday protest significantly different? No at p<.05
oneway ppart dow, tab
pwmean ppart, over(dow) mcompare(tukey) effects

*Difference in means using non-parametric? No at p<.05
kwallis ppart, by(dow)

*Which category dominates? None
conovertest ppart, by(dow)

*nbreg with Newy-West Se's
tsset date, daily
glm ppart i.dow, family(nbinom) vce(hac nwest 1)

coefplot, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-4 -2 0 2 4) ///
	ylabel(1 "M" 2 "T" 3 "W" 4 "T" 5 "F" 6 "S", labsize(small)) ///
	aspectratio(1)

preserve
collapse (sum) ppart, by(dow)
twoway bar ppart dow, ///
	tlabel(0 "S" 1 "M" 2 "T" 3 "W" 4 "T" 5 "F" 6 "S") ///
	aspectratio(1) ///
	xtitle("") ///
	ytitle(Protest participation) ylabel(, angle(90) labsize(small)) ///
	ylabel(,nogrid) barw(0.9)	
restore

********************************************************************************
* Fig 5.: Tunisia participation by dow and coefplot
********************************************************************************

use tun_prot_expanded.dta, clear

*NBreg with Newey-West Se's and Monday as ref 
tsset date, daily
glm ppart ib1.dow, family(nbinom) vce(hac nwest 1)

coefplot, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-4 -2 0 2 4) ///
	ylabel(1 "S" 2 "T" 3 "W" 4 "T" 5 "F" 6 "S", labsize(small)) ///
	aspectratio(1) plotregion(margin(zero))

collapse(sum) ppart lab_ppart, by(dow)
lab var ppart "Non-labor"
lab var lab_ppart "Organized labor"

twoway bar ppart dow, barw(0.9) || bar lab_ppart dow, barw(0.9) ///
	tlabel(0 "S" 1 "M" 2 "T" 3 "W" 4 "T" 5 "F" 6 "S") ///
	aspectratio(1) ///
	xtitle("") ///
	ytitle("") ///
	ylabel(, angle(90) labsize(small)) ///
	legend(position(6) cols(2)) ylabel(,nogrid)

********************************************************************************
* Fig 6.: Tunisia mass mobilization
********************************************************************************
	
use massmobtun.dta, clear

twoway bar ppart stdate, xla(18613(7)18992, format("%tdDa") labsize(tiny) labcolor("189 30 36")) ///
xmla(18641 "Ben Ali departure" 18654 "Kasbah 1" 18683 "Kasbah 2" ///
	18717 "Lawyers strike" 18757 "UGTT regional general strike", tlcolor(%20) angle(90) labsize(small) tlength(*10)) ///
	xtitle("") yline(10000, lcolor("189 30 36")) ysize(4) /// 
	ytitle(Protest participation (million), size(small)) lwidth(0) ///
	ylabel(0 "0" 50000 "0.05" 100000 "0.1" 150000 "0.15" 200000 "0.2", angle(90) labsize(small) nogrid) ///
	plotregion(margin(zero)) title("")

********************************************************************************
* Sector, Location, Repertoire plots: Egypt
********************************************************************************

**** Sector ****

use egysec.dta, clear

tsset date, daily
glm studentsppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model1, title("Students")
 
glm residentsppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model2, title("Residents")

glm activistssppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model3, title("Activists")

glm lab_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model4, title("Labour")

coefplot model1, bylabel("") ///
|| model2, bylabel("") ///
|| model3, bylabel("") ///
|| model4, bylabel("") ///
||, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-6 -4 -2 0 2 4 6) ///
	mlabposition(4) mlabsize(medlarge) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", "")))) ///
	ylabel(1 "Monday" 2 "Tuesday" 3 "Wednesday" 4 "Thursday" 5 "Friday" 6 "Saturday") ///
	aspectratio(1) grid(no) ///
		legend(lab (2 "Students") lab(4 "Residents") lab(6 "Activists") lab(8 "Labour") cols(4) note("* p < .05, ** p < .01, *** p < .001")) ///
		norecycle plotregion(margin(zero)) byopts(cols(4))


eststo clear		
recode dow(0=0 "Sunday")(1=1 "Monday")(2=2 "Tuesday")(3=3 "Wednesday")(4=4 "Thursday")(5=5 "Friday")(6=6 "Saturday"), into(dow1)
tsset date, daily
qui eststo: glm studentsppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm residentsppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm activistssppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm lab_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
 
esttab, ///
 se(3) b(3) mtitle("Mod. 1: students" "Mod. 2: residents" "Mod. 3: activists" "Mod. 4: labour") ///
 label nonumber noobs nobaselevels eqlabels(none) drop(_cons) scalars("refcat Ref. day") ///
 title("Protest participation by sector: Egypt. Negative binomial regression with Sunday as reference day.")
 
**** Location **** 

use egyloc.dta, clear

tsset date, daily

glm workplaces_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model1

glm campuses_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model2

glm public_space_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model3

glm worship_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model4

coefplot model1, bylabel("") ///
|| model2, bylabel("") ///
|| model3, bylabel("") ///
|| model4, bylabel("") ///
||, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-6 -4 -2 0 2 4 6) ///
	mlabposition(4) mlabsize(medlarge) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", "")))) ///
	ylabel(1 "Monday" 2 "Tuesday" 3 "Wednesday" 4 "Thursday" 5 "Friday" 6 "Saturday") ///
	aspectratio(1) grid(no) ///
		legend(lab (2 "Workplaces") lab(4 "Campuses") lab(6 "Public space") lab(8 "Worship") cols(4) note("* p < .05, ** p < .01, *** p < .001")) ///
		norecycle ///
		plotregion(margin(zero)) byopts(cols(4))

eststo clear
recode dow(0=0 "Sunday")(1=1 "Monday")(2=2 "Tuesday")(3=3 "Wednesday")(4=4 "Thursday")(5=5 "Friday")(6=6 "Saturday"), into(dow1)
tsset date, daily
qui eststo: glm workplaces_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm campuses_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm public_space_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm worship_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"

esttab, ///
 se(3) b(3) mtitle("Mod. 1: workplace" "Mod. 2: campus" "Mod. 3: pub. space" "Mod. 4: worship") ///
 label nonumber noobs nobaselevels eqlabels(none) drop(_cons) scalars("refcat Ref. day") ///
 title("Protest participation by location: Egypt. Negative binomial regression with Sunday as reference day.")
 
**** Repertoire ****
 
use egyrep.dta, clear

tsset date, daily

glm disruptive_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model1

glm transitory_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model2

glm economic_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model3

glm static_ppart i.dow, family(nbinom) vce(hac nwest 1)
estimates store model4

coefplot model1, bylabel("") ///
|| model2, bylabel("") ///
|| model3, bylabel("") ///
|| model4, bylabel("") ///
||, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-6 -4 -2 0 2 4 6) ///
	mlabposition(4) mlabsize(medlarge) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", "")))) ///
	ylabel(1 "Monday" 2 "Tuesday" 3 "Wednesday" 4 "Thursday" 5 "Friday" 6 "Saturday") ///
	aspectratio(1) grid(no) ///
		legend(lab (2 "Disruptive") lab(4 "Transitory") lab(6 "Economic") lab(8 "Static") cols(4) note("* p < .05, ** p < .01, *** p < .001")) ///
		norecycle ///
		plotregion(margin(zero)) byopts(cols(4))
		
eststo clear
recode dow(0=0 "Sunday")(1=1 "Monday")(2=2 "Tuesday")(3=3 "Wednesday")(4=4 "Thursday")(5=5 "Friday")(6=6 "Saturday"), into(dow1)
tsset date, daily
qui eststo: glm disruptive_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm transitory_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm economic_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
qui eststo: glm static_ppart i.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Sunday"
 
esttab, ///
 se(3) b(3) mtitle("Mod. 1: disruptive" "Mod. 2: transitory" "Mod. 3: economic" "Mod. 4: static") ///
 label nonumber noobs nobaselevels eqlabels(none) drop(_cons) scalars("refcat Ref. day") ///
 title("Protest participation by repertoire: Egypt. Negative binomial regression with Sunday as reference day.")

********************************************************************************
* Sector, Location, Repertoire plots: Tunisia
********************************************************************************

**** Sector ****

use tunsec.dta, clear

tsset date, daily

*University ppart
glm studentsppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model1, title("Students")

*Residents 
glm residentsppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model2, title("Residents")

*Social movements/activists
glm activistssppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model3, title("Activists")

*Labour
glm lab_ppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model4, title("Labour")

coefplot model1, bylabel("") ///
|| model2, bylabel("") ///
|| model3, bylabel("") ///
|| model4, bylabel("") ///
||, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-6 -4 -2 0 2 4 6) ///
	mlabposition(4) mlabsize(medlarge) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", "")))) ///
	ylabel(1 "Sunday" 2 "Tuesday" 3 "Wednesday" 4 "Thursday" 5 "Friday" 6 "Saturday") ///
	aspectratio(1) grid(no) ///
		legend(lab (2 "Students") lab(4 "Residents") lab(6 "Activists") lab(8 "Labour") cols(4) note("* p < .05, ** p < .01, *** p < .001")) ///
	norecycle ///
	plotregion(margin(zero)) byopts(cols(4))

recode dow(0=0 "Sunday")(1=1 "Monday")(2=2 "Tuesday")(3=3 "Wednesday")(4=4 "Thursday")(5=5 "Friday")(6=6 "Saturday"), into(dow1)
tsset date, daily
eststo clear
qui eststo: glm studentsppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm residentsppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm activistssppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm lab_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
 
esttab, ///
 se(3) b(3) mtitle("Mod. 1: students" "Mod. 2: residents" "Mod. 3: activists" "Mod. 4: labour") ///
 label nonumber noobs nobaselevels eqlabels(none) drop(_cons) scalars("refcat Ref. day") ///
 title("Protest participation by sector: Tunisia. Negative binomial regression with Monday as reference day.")
 
**** Location ****

use tunloc.dta, clear

tsset date, daily

glm workplaces_ppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model1

glm campuses_ppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model2

glm public_space_ppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model3

glm ugtt_ppart ib1.dow, family(nbinom) vce(hac nwest 1)
estimates store model4

coefplot model1, bylabel("") ///
|| model2, bylabel("") ///
|| model3, bylabel("") ///
|| model4, bylabel("") ///
||, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-6 -4 -2 0 2 4 6) ///
	mlabposition(4) mlabsize(medlarge) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", "")))) ///
	ylabel(1 "Sunday" 2 "Tuesday" 3 "Wednesday" 4 "Thursday" 5 "Friday" 6 "Saturday") ///
	aspectratio(1) grid(no) ///
		legend(lab (2 "Workplaces") lab(4 "Campuses") lab(6 "Public space") lab(8 "Trade union") cols(4) note("* p < .05, ** p < .01, *** p < .001")) ///
	norecycle ///
	plotregion(margin(zero)) byopts(cols(4))

eststo clear
recode dow(0=0 "Sunday")(1=1 "Monday")(2=2 "Tuesday")(3=3 "Wednesday")(4=4 "Thursday")(5=5 "Friday")(6=6 "Saturday"), into(dow1)
tsset date, daily
qui eststo: glm workplaces_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm campuses_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm public_space_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm ugtt_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
 
esttab, ///
 se(3) b(3) mtitle("Mod. 1: workplace" "Mod. 2: campus" "Mod. 3: pub. space" "Mod. 4: trad. un.") ///
 label nonumber noobs nobaselevels eqlabels(none) drop(_cons) scalars("refcat Ref. day") ///
 title("Protest participation by location: Tunisia. Negative binomial regression with Monday as reference day.")
 
**** Repertoire **** 

use tunrep.dta, clear

tsset date, daily

glm disruptive_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estimates store model1

glm transitory_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estimates store model2

glm economic_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estimates store model3

glm static_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estimates store model4

coefplot model1, bylabel("") ///
|| model2, bylabel("") ///
|| model3, bylabel("") ///
|| model4, bylabel("") ///
||, xline(0, lwidth(.2)) drop(_cons) ///
	xlabel(-6 -4 -2 0 2 4 6) ///
	mlabposition(4) mlabsize(medlarge) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", "")))) ///
	ylabel(1 "Sunday" 2 "Tuesday" 3 "Wednesday" 4 "Thursday" 5 "Friday" 6 "Saturday") ///
	aspectratio(1) grid(no) ///
		legend(lab (2 "Disruptive") lab(4 "Transitory") lab(6 "Economic") lab(8 "Static") cols(4) note("* p < .05, ** p < .01, *** p < .001")) ///
	norecycle ///
	plotregion(margin(zero)) byopts(cols(4))

eststo clear
recode dow(0=0 "Sunday")(1=1 "Monday")(2=2 "Tuesday")(3=3 "Wednesday")(4=4 "Thursday")(5=5 "Friday")(6=6 "Saturday"), into(dow1)
tsset date, daily
qui eststo: glm disruptive_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm transitory_ppart ib1.dow1, family(nbinom) vce(hac nwest 
estadd local refcat "Monday"
qui eststo: glm economic_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
qui eststo: glm static_ppart ib1.dow1, family(nbinom) vce(hac nwest 1)
estadd local refcat "Monday"
 
esttab, ///
 se(3) b(3) mtitle("Mod. 1: disruptive" "Mod. 2: transitory" "Mod. 3: economic" "Mod. 4: static") ///
 label nonumber noobs nobaselevels eqlabels(none) drop(_cons) scalars("refcat Ref. day") ///
 title("Protest participation by repertoire: Tunisia. Negative binomial regression with Monday as reference day.") 
	
